package com.kim.authorization.server.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;

/**
 * WebConfig
 * <p>
 *     暂时弃用详情见{@link org.apache.ibatis.parsing.TokenHandler}
 *     启用时记得加注解{@code @Configuration}
 * </p>
 */
@Order(1)
@Deprecated
public class WebConfig {

    /**
     * 配置Token处理过滤器
     */
    @Bean
    public FilterRegistrationBean tokenHandleFilter() {
        FilterRegistrationBean<TokenHandleFilter> filterRegistrationBean = new FilterRegistrationBean<>();

        TokenHandleFilter tokenHandleFilter = new TokenHandleFilter();
        filterRegistrationBean.setFilter(tokenHandleFilter);
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("/oauth/token");
        //设置init参数
        filterRegistrationBean.addInitParameter("init","Init tokenHandleFilter");
        //设置过滤器名称
        filterRegistrationBean.setName("tokenHandleFilter");
        filterRegistrationBean.getServletRegistrationBeans();
        //执行次序
        filterRegistrationBean.setOrder(Integer.MIN_VALUE);
        return filterRegistrationBean;
    }
}
